#ifndef _OLED_H_
#define _OLED_H_

#include "oled_font.h"
#include "main.h"
#include "i2c.h"

#define TURN_OFF_OLED_PANEL Oled_Write_CMD(0xAE);//--turn off oled panel
#define SET_LOW_COLUMN_ADDRESS Oled_Write_CMD(0x02);//---SET low column address
#define SET_HIGH_COLUMN_ADDRESS Oled_Write_CMD(0x10);//---SET high column address
#define SET_START_LINE Oled_Write_CMD(0x40);//--SET start line address  SET Mapping RAM Display Start Line (0x00~0x3F)
#define SET_CONTRAST_CONTROL Oled_Write_CMD(0x81);//--SET contrast control register
#define SET_OUTPUT_CURRENT_BRIGHT Oled_Write_CMD(0xCF); // SET SEG Output Current Brightness
#define SET_SEG_MAPPING Oled_Write_CMD(0xA1);//--SET SEG/Column Mapping     0xa0左右反置 0xa1正常
#define SET_SCAN_DIRECTION Oled_Write_CMD(0xC8);//SET COM/Row Scan Direction   0xc0上下反置 0xc8正常
#define SET_NORMAL_DISPLAY Oled_Write_CMD(0xA6);//--SET normal display
#define SET_MULTIPLEX RATIO Oled_Write_CMD(0xA8);//--SET multiplex ratio(1 to 64)
#define SET_DUTY Oled_Write_CMD(0x3f);//--1/64 duty
#define SET_DISPLAY_OFFSET Oled_Write_CMD(0xD3);//-SET display offSET	Shift Mapping RAM Counter (0x00~0x3F)
#define SET_NOT_OFFSET Oled_Write_CMD(0x00);//-not offSET
#define SET_DISPLAY_CLOCK Oled_Write_CMD(0xd5);//--SET display clock divide ratio/oscillator frequency
#define SET_DIVIDE_RATIO Oled_Write_CMD(0x80);//--SET divide ratio, SET Clock as 100 Frames/Sec
#define SET_PRE_CHARGE Oled_Write_CMD(0xD9);//--SET pre-charge period
#define SET_PRE_CHARGE_15 Oled_Write_CMD(0xF1);//SET Pre-Charge as 15 Clocks & Discharge as 1 Clock
#define SET_COM_PINS Oled_Write_CMD(0xDA);//--SET com pins hardware configuration
#define SET_COM_PINS_12 Oled_Write_CMD(0x12);
#define SET_VCOMH Oled_Write_CMD(0xDB);//--SET vcomh
#define SET_VCOM_DESELECT_LEVEL Oled_Write_CMD(0x40);//SET VCOM Deselect Level
#define SET_PAGE_ADDRESS_MODE Oled_Write_CMD(0x20);//-SET Page Addressing Mode (0x00/0x01/0x02)
#define SET_PAGE_ADDRESS_MODE_2 Oled_Write_CMD(0x02);//
#define SET_CHARGE_PUMP Oled_Write_CMD(0x8D);//--SET Charge Pump enable/disable
#define SET_DISABLE_10 Oled_Write_CMD(0x14);//--SET(0x10) disable
#define SET DISABLE_ENTIRE_DISPLAY_ON Oled_Write_CMD(0xA4);// Disable Entire Display On (0xa4/0xa5)
#define SET_INVERSE_DISPLAY_ON Oled_Write_CMD(0xA6);// Disable Inverse Display On (0xa6/a7)
#define SET_TURN_ON_PANEL Oled_Write_CMD(0xAF);//--turn on oled panel
#define SET_DISPLAY_ON Oled_Write_CMD(0xAF); /*display ON*/

//static const uint8_t OLED_START[] = {'H', 'e', 'l', 'l', 'o', ',', 'W', 'e', 'l', 'c', 'o', 'm', 'e', '!'};
static const uint8_t OLED_START[] = "Hello,Welcome!";

void Oled_Init();
void Oled_Clear();
void Oled_Write_CMD(uint8_t cmd);
void Oled_Write_Data(uint8_t data);
void Oled_Display_On(void);
void OLED_Display_Off(void);
void Oled_Show_Char(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size);
void Oled_Show_String(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size);



#endif
